<?php
namespace app\controller;

use app\BaseController;
use app\model\Classify;
use app\model\SysUser;
use think\facade\View;

/**
 * 优秀企业汇展
 */
class Excellent extends BaseController
{
    public function index()
    {

        // 获取所有分类
        $industry = Classify::where(['deleted' => 0,'status_flag' => 0])->order("listorder")->select();
        // 循环分类 获取最新的企业 6个
        foreach ($industry as $key => $value) {
            // 分类id
            $classify_id = $value['id'];
            // 获取分类下的企业
            $company_list = SysUser::where(['classify_id' => $classify_id, 'deleted' => 0,'status' => 0])
                ->order('create_time desc')->limit(8)->select();
            $value['list'] = $company_list->toArray();
        }

        // 返回页面
        View::assign('industry', $industry);

        // 如果是手机访问
        if ($this->isMobile())
        {
            return View::fetch('wap_index');
        } else {
            return View::fetch();
        }
    }


    /**
     * 企业详情
     */
    public function detail($id = null)
    {
        // 推荐的八个企业 图片 + 企业名称
        $recommend = [
            ['title' => '企业1', 'logo' => '/static/images/icon_qy01.png', 'id'=> 1],
            ['title' => '企业2', 'logo' => '/static/images/icon_qy02.png', 'id'=> 1],
            ['title' => '企业3', 'logo' => '/static/images/icon_qy03.png', 'id'=> 1],
            ['title' => '企业4', 'logo' => '/static/images/icon_qy04.png', 'id'=> 1],
            ['title' => '企业5', 'logo' => '/static/images/icon_qy05.png', 'id'=> 1],
            ['title' => '企业6', 'logo' => '/static/images/icon_qy06.png', 'id'=> 1],
            ['title' => '企业7', 'logo' => '/static/images/icon_qy07.png', 'id'=> 1],
//            ['title' => '企业8', 'logo' => '/static/images/icon_qy08.png', 'id'=> 1],
        ];
        View::assign('recommend', $recommend);


        // 如果是手机访问
        if ($this->isMobile())
        {
            return View::fetch('wap_detail');
        } else {
            return View::fetch();
        }
    }


}
